from dao.DAOQuanLyNhanVien import DaoQuanLyNhanVien
from google.appengine.api import users
import WSGI
import logging
import webapp2

logger = logging.getLogger("GUIError")

class GuiError(webapp2.RequestHandler):
    def get(self):
        user = users.get_current_user()
        nv = DaoQuanLyNhanVien.getNhanVienByUsername(user.nickname())
        if nv is not None:
            lstPriv = DaoQuanLyNhanVien.getListStaffPriviledge(nv.key().id())
            if lstPriv.has_key('KinhDoanh.QuanLyDonHang') or lstPriv.has_key('Xuong.HangSanXuatHomNay'):
                self.redirect('/')
        template_values = {
                        'nickname': users.get_current_user().nickname(),
                        'signOutUrl': users.create_logout_url("/")}
        template = WSGI.jinja_environment.get_template('/html/Home.html')
        self.response.out.write(template.render(template_values))
            
        